<template>
<div class="search-bt">
    <el-input 
        clearable placeholder="请输入名称 / 标签" 
        v-model="keyWord" 
        class="input-with-select"
        @keyup.enter.native="onSearch">
        <el-button 
            slot="append" 
            icon="el-icon-search"
            @click='onSearch'>
        </el-button>
    </el-input>
</div>
</template>

<script>
//搜索输入框组件
export default {
    props:{
        dataType:{  //搜索数据的类型
            type:Number,
            default:1,
        },
    },
    data(){
        return{
            keyWord:'',
        };
    },
    methods:{
        onSearch(){
            this.$router.push({
                path: '/search',
                query: {
                    keyWord: this.keyWord,
                    dataType:this.dataType,
                },
            }).catch(()=>{return;});
        },
    },
}
</script>
<style lang="scss" scoped>
.search-bt{
    background-color: white;
    height: fit-content;
    font-size: 1.2rem;
    border-radius: 4px;
    border: 2px solid #ffffff;
    box-sizing: border-box;
    border: 1px solid #e9f2f9;
    padding:3px;
    transition: all 0.2s;
    /deep/.el-input__inner{
        border:none;
        padding: 0;
        padding-left: 20px;
    }
    /deep/.el-input-group__append{
        border:none;
        border-radius: 4px;
        overflow: hidden;
    }
    /deep/i{
        font-size: 1.5rem;
    }
    /deep/input{
        &:focus{
            border-color: #DCDFE6;
        }
    }
    &:focus-within{
        border-color: #ffd966 !important;
    }
}
</style>

